/**
* Copyright (C) 2013 kangliqiang ,kangliq@163.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "MQProtos.h"

namespace rmq
{

const char* getMQRequestCodeString(int code)
{
    switch (code)
    {
		case SEND_MESSAGE_VALUE:
			return "SEND_MESSAGE_VALUE";
		case PULL_MESSAGE_VALUE:
			return "PULL_MESSAGE_VALUE";
		case QUERY_MESSAGE_VALUE:
			return "QUERY_MESSAGE_VALUE";
		case QUERY_BROKER_OFFSET_VALUE:
			return "QUERY_BROKER_OFFSET_VALUE";
		case QUERY_CONSUMER_OFFSET_VALUE:
			return "QUERY_CONSUMER_OFFSET_VALUE";
		case UPDATE_CONSUMER_OFFSET_VALUE:
			return "UPDATE_CONSUMER_OFFSET_VALUE";
		case UPDATE_AND_CREATE_TOPIC_VALUE:
			return "UPDATE_AND_CREATE_TOPIC_VALUE";
		case GET_ALL_TOPIC_CONFIG_VALUE:
			return "GET_ALL_TOPIC_CONFIG_VALUE";
		case GET_TOPIC_CONFIG_LIST_VALUE:
			return "GET_TOPIC_CONFIG_LIST_VALUE";
		case GET_TOPIC_NAME_LIST_VALUE:
			return "GET_TOPIC_NAME_LIST_VALUE";
		case UPDATE_BROKER_CONFIG_VALUE:
			return "UPDATE_BROKER_CONFIG_VALUE";
		case GET_BROKER_CONFIG_VALUE:
			return "GET_BROKER_CONFIG_VALUE";
		case TRIGGER_DELETE_FILES_VALUE:
			return "TRIGGER_DELETE_FILES_VALUE";
		case GET_BROKER_RUNTIME_INFO_VALUE:
			return "GET_BROKER_RUNTIME_INFO_VALUE";
		case SEARCH_OFFSET_BY_TIMESTAMP_VALUE:
			return "SEARCH_OFFSET_BY_TIMESTAMP_VALUE";
		case GET_MAX_OFFSET_VALUE:
			return "GET_MAX_OFFSET_VALUE";
		case GET_MIN_OFFSET_VALUE:
			return "GET_MIN_OFFSET_VALUE";
		case GET_EARLIEST_MSG_STORETIME_VALUE:
			return "GET_EARLIEST_MSG_STORETIME_VALUE";
		case VIEW_MESSAGE_BY_ID_VALUE:
			return "VIEW_MESSAGE_BY_ID_VALUE";
		case HEART_BEAT_VALUE:
			return "HEART_BEAT_VALUE";
		case UNREGISTER_CLIENT_VALUE:
			return "UNREGISTER_CLIENT_VALUE";
		case CONSUMER_SEND_MSG_BACK_VALUE:
			return "CONSUMER_SEND_MSG_BACK_VALUE";
		case END_TRANSACTION_VALUE:
			return "END_TRANSACTION_VALUE";
		case GET_CONSUMER_LIST_BY_GROUP_VALUE:
			return "GET_CONSUMER_LIST_BY_GROUP_VALUE";
		case CHECK_TRANSACTION_STATE_VALUE:
			return "CHECK_TRANSACTION_STATE_VALUE";
		case NOTIFY_CONSUMER_IDS_CHANGED_VALUE:
			return "NOTIFY_CONSUMER_IDS_CHANGED_VALUE";
		case LOCK_BATCH_MQ_VALUE:
			return "LOCK_BATCH_MQ_VALUE";
		case UNLOCK_BATCH_MQ_VALUE:
			return "UNLOCK_BATCH_MQ_VALUE";
		case GET_ALL_CONSUMER_OFFSET_VALUE:
			return "GET_ALL_CONSUMER_OFFSET_VALUE";
		case GET_ALL_DELAY_OFFSET_VALUE:
			return "GET_ALL_DELAY_OFFSET_VALUE";
		case PUT_KV_CONFIG_VALUE:
			return "PUT_KV_CONFIG_VALUE";
		case GET_KV_CONFIG_VALUE:
			return "GET_KV_CONFIG_VALUE";
		case DELETE_KV_CONFIG_VALUE:
			return "DELETE_KV_CONFIG_VALUE";
		case REGISTER_BROKER_VALUE:
			return "REGISTER_BROKER_VALUE";
		case UNREGISTER_BROKER_VALUE:
			return "UNREGISTER_BROKER_VALUE";
		case GET_ROUTEINTO_BY_TOPIC_VALUE:
			return "GET_ROUTEINTO_BY_TOPIC_VALUE";
		case GET_BROKER_CLUSTER_INFO_VALUE:
			return "GET_BROKER_CLUSTER_INFO_VALUE";
		case UPDATE_AND_CREATE_SUBSCRIPTIONGROUP_VALUE:
			return "UPDATE_AND_CREATE_SUBSCRIPTIONGROUP_VALUE";
		case GET_ALL_SUBSCRIPTIONGROUP_CONFIG_VALUE:
			return "GET_ALL_SUBSCRIPTIONGROUP_CONFIG_VALUE";
		case GET_TOPIC_STATS_INFO_VALUE:
			return "GET_TOPIC_STATS_INFO_VALUE";
		case GET_CONSUMER_CONNECTION_LIST_VALUE:
			return "GET_CONSUMER_CONNECTION_LIST_VALUE";
		case GET_PRODUCER_CONNECTION_LIST_VALUE:
			return "GET_PRODUCER_CONNECTION_LIST_VALUE";
		case WIPE_WRITE_PERM_OF_BROKER_VALUE:
			return "WIPE_WRITE_PERM_OF_BROKER_VALUE";
		case GET_ALL_TOPIC_LIST_FROM_NAMESERVER_VALUE:
			return "GET_ALL_TOPIC_LIST_FROM_NAMESERVER_VALUE";
		case DELETE_SUBSCRIPTIONGROUP_VALUE:
			return "DELETE_SUBSCRIPTIONGROUP_VALUE";
		case GET_CONSUME_STATS_VALUE:
			return "GET_CONSUME_STATS_VALUE";
		case SUSPEND_CONSUMER_VALUE:
			return "SUSPEND_CONSUMER_VALUE";
		case RESUME_CONSUMER_VALUE:
			return "RESUME_CONSUMER_VALUE";
		case RESET_CONSUMER_OFFSET_IN_CONSUMER_VALUE:
			return "RESET_CONSUMER_OFFSET_IN_CONSUMER_VALUE";
		case RESET_CONSUMER_OFFSET_IN_BROKER_VALUE:
			return "RESET_CONSUMER_OFFSET_IN_BROKER_VALUE";
		case ADJUST_CONSUMER_THREAD_POOL_VALUE:
			return "ADJUST_CONSUMER_THREAD_POOL_VALUE";
		case WHO_CONSUME_THE_MESSAGE_VALUE:
			return "WHO_CONSUME_THE_MESSAGE_VALUE";
		case DELETE_TOPIC_IN_BROKER_VALUE:
			return "DELETE_TOPIC_IN_BROKER_VALUE";
		case DELETE_TOPIC_IN_NAMESRV_VALUE:
			return "DELETE_TOPIC_IN_NAMESRV_VALUE";
		case GET_KV_CONFIG_BY_VALUE_VALUE:
			return "GET_KV_CONFIG_BY_VALUE_VALUE";
		case DELETE_KV_CONFIG_BY_VALUE_VALUE:
			return "DELETE_KV_CONFIG_BY_VALUE_VALUE";
		case GET_KVLIST_BY_NAMESPACE_VALUE:
			return "GET_KVLIST_BY_NAMESPACE_VALUE";
		case RESET_CONSUMER_CLIENT_OFFSET_VALUE:
			return "RESET_CONSUMER_CLIENT_OFFSET_VALUE";
		case GET_CONSUMER_STATUS_FROM_CLIENT_VALUE:
			return "GET_CONSUMER_STATUS_FROM_CLIENT_VALUE";
		case INVOKE_BROKER_TO_RESET_OFFSET_VALUE:
			return "INVOKE_BROKER_TO_RESET_OFFSET_VALUE";
		case INVOKE_BROKER_TO_GET_CONSUMER_STATUS_VALUE:
			return "INVOKE_BROKER_TO_GET_CONSUMER_STATUS_VALUE";
		case QUERY_TOPIC_CONSUME_BY_WHO_VALUE:
			return "QUERY_TOPIC_CONSUME_BY_WHO_VALUE";
		case GET_TOPICS_BY_CLUSTER_VALUE:
			return "GET_TOPICS_BY_CLUSTER_VALUE";
		case REGISTER_FILTER_SERVER_VALUE:
			return "REGISTER_FILTER_SERVER_VALUE";
		case REGISTER_MESSAGE_FILTER_CLASS_VALUE:
			return "REGISTER_MESSAGE_FILTER_CLASS_VALUE";
		case QUERY_CONSUME_TIME_SPAN_VALUE:
			return "QUERY_CONSUME_TIME_SPAN_VALUE";
		case GET_SYSTEM_TOPIC_LIST_FROM_NS_VALUE:
			return "GET_SYSTEM_TOPIC_LIST_FROM_NS_VALUE";
		case GET_SYSTEM_TOPIC_LIST_FROM_BROKER_VALUE:
			return "GET_SYSTEM_TOPIC_LIST_FROM_BROKER_VALUE";
		case CLEAN_EXPIRED_CONSUMEQUEUE_VALUE:
			return "CLEAN_EXPIRED_CONSUMEQUEUE_VALUE";
		case GET_CONSUMER_RUNNING_INFO_VALUE:
			return "GET_CONSUMER_RUNNING_INFO_VALUE";
		case QUERY_CORRECTION_OFFSET_VALUE:
			return "QUERY_CORRECTION_OFFSET_VALUE";
		case CONSUME_MESSAGE_DIRECTLY_VALUE:
			return "CONSUME_MESSAGE_DIRECTLY_VALUE";
		case SEND_MESSAGE_V2_VALUE:
			return "SEND_MESSAGE_V2_VALUE";
		case GET_UNIT_TOPIC_LIST_VALUE:
			return "GET_UNIT_TOPIC_LIST_VALUE";
		case GET_HAS_UNIT_SUB_TOPIC_LIST_VALUE:
			return "GET_HAS_UNIT_SUB_TOPIC_LIST_VALUE";
		case GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST_VALUE:
			return "GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST_VALUE";
		case CLONE_GROUP_OFFSET_VALUE:
			return "CLONE_GROUP_OFFSET_VALUE";
		case VIEW_BROKER_STATS_DATA_VALUE:
			return "VIEW_BROKER_STATS_DATA_VALUE";
    }

    return "UnknowMQRequestCode";
}

const char* getMQResponseCodeString(int code)
{
    switch (code)
    {
		case 0:
			return "OK";
		case FLUSH_DISK_TIMEOUT_VALUE:
			return "FLUSH_DISK_TIMEOUT_VALUE";
		case SLAVE_NOT_AVAILABLE_VALUE:
			return "SLAVE_NOT_AVAILABLE_VALUE";
		case FLUSH_SLAVE_TIMEOUT_VALUE:
			return "FLUSH_SLAVE_TIMEOUT_VALUE";
		case MESSAGE_ILLEGAL_VALUE:
			return "MESSAGE_ILLEGAL_VALUE";
		case SERVICE_NOT_AVAILABLE_VALUE:
			return "SERVICE_NOT_AVAILABLE_VALUE";
		case VERSION_NOT_SUPPORTED_VALUE:
			return "VERSION_NOT_SUPPORTED_VALUE";
		case NO_PERMISSION_VALUE:
			return "NO_PERMISSION_VALUE";
		case TOPIC_NOT_EXIST_VALUE:
			return "TOPIC_NOT_EXIST_VALUE";
		case TOPIC_EXIST_ALREADY_VALUE:
			return "TOPIC_EXIST_ALREADY_VALUE";
		case PULL_NOT_FOUND_VALUE:
			return "PULL_NOT_FOUND_VALUE";
		case PULL_RETRY_IMMEDIATELY_VALUE:
			return "PULL_RETRY_IMMEDIATELY_VALUE";
		case PULL_OFFSET_MOVED_VALUE:
			return "PULL_OFFSET_MOVED_VALUE";
		case QUERY_NOT_FOUND_VALUE:
			return "QUERY_NOT_FOUND_VALUE";
		case SUBSCRIPTION_PARSE_FAILED_VALUE:
			return "SUBSCRIPTION_PARSE_FAILED_VALUE";
		case SUBSCRIPTION_NOT_EXIST_VALUE:
			return "SUBSCRIPTION_NOT_EXIST_VALUE";
		case SUBSCRIPTION_NOT_LATEST_VALUE:
			return "SUBSCRIPTION_NOT_LATEST_VALUE";
		case SUBSCRIPTION_GROUP_NOT_EXIST_VALUE:
			return "SUBSCRIPTION_GROUP_NOT_EXIST_VALUE";
		case TRANSACTION_SHOULD_COMMIT_VALUE:
			return "TRANSACTION_SHOULD_COMMIT_VALUE";
		case TRANSACTION_SHOULD_ROLLBACK_VALUE:
			return "TRANSACTION_SHOULD_ROLLBACK_VALUE";
		case TRANSACTION_STATE_UNKNOW_VALUE:
			return "TRANSACTION_STATE_UNKNOW_VALUE";
		case TRANSACTION_STATE_GROUP_WRONG_VALUE:
			return "TRANSACTION_STATE_GROUP_WRONG_VALUE";
		case NO_BUYER_ID_VALUE:
			return "NO_BUYER_ID_VALUE";
		case NOT_IN_CURRENT_UNIT_VALUE:
			return "NOT_IN_CURRENT_UNIT_VALUE";
		case CONSUMER_NOT_ONLINE_VALUE:
			return "CONSUMER_NOT_ONLINE_VALUE";
		case CONSUME_MSG_TIMEOUT_VALUE:
			return "CONSUME_MSG_TIMEOUT_VALUE";
    }

    return "UnknowMQResponseCode";
}

}
